import React, { Component } from 'react';
import { createPage } from "nc-lightapp-front";
import initTemplate from './initTemplate'
import queryData from './queryData'
import { setTable } from '../../../utils/setComponentUsed'

class LinkBillModal extends Component {
    constructor(props) {
        super(props);
        setTable(props, props.tableAreaId);
        initTemplate.call(this, props);
    }

    componentDidMount() {
        queryData.call(this);
    }

    /**
     * 设置表格数据
     * @param {*} data 
     */
    setAllTableData(data){
        this.props.table.setAllTableData(this.props.tableAreaId, data);
    }

    /**
     * 行双击事件
     * @param {*} record 
     * @param {*} index 
     * @param {*} props 
     */
    onRowDoubleClick(record, index, props){
        this.props.onRowDoubleClick && this.props.onRowDoubleClick(record, index);
    }

    render() {
        return (
            this.props.modal.createModal('components_linkBusiBillModal', {
                // 1058-SP-0043: 联查单据
                title: this.props.modalTitle,
                content: (
                    <div className="nc-bill-list">
                        <div className="nc-bill-table-area">
                            {this.props.table.createSimpleTable(this.props.tableAreaId, {
                                showIndex: this.props.showIndex || true,
                                adaptionHeight: this.props.adaptionHeight || true,
                                onRowDoubleClick: (...params)=>{this.onRowDoubleClick.call(this, ...params)}
                            })}
                        </div>
                    </div>
                ),
                size: this.props.size || 'xlg',
                noFooter: this.props.noFooter || true,
                closeModalEve: () => {
                    this.props.closeModalEve && this.props.closeModalEve();
                }
            })
        )
    }
}
LinkBillModal = createPage({})(LinkBillModal);
export default LinkBillModal
